//
//	DirectoryList by J Brown
//
//	Combo box must have the following styles set:
//
//	CBS_OWNERDRAWFIXED, CBS_HASSTRINGS, CBS_DROPDOWNLIST
//
#include <windows.h>
#include "DriveList.h"
#include "resource.h"

BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	UINT uCmd = HIWORD(wParam), uCtrlId = LOWORD(wParam);

	switch(msg)
	{
	case WM_INITDIALOG:
		MakeDriveList(GetDlgItem(hwnd, IDC_COMBO1));
		return TRUE;

	case WM_COMMAND:
		
		switch(uCtrlId)
		{
		case IDOK: case IDCANCEL:
			EndDialog(hwnd, 0);
			return TRUE;

		case IDC_COMBO1:
			if(uCmd == CBN_SELCHANGE)
			{
				char ach[32];
				DriveList_GetDrive((HWND)lParam, ach);
			}
		}
		
		return FALSE;

	case WM_MEASUREITEM:
		if(wParam == IDC_COMBO1)
		{
			return DriveListMeasure(hwnd, wParam, (MEASUREITEMSTRUCT *)lParam);
		}

		return FALSE;

	case WM_DRAWITEM:
		if(wParam == IDC_COMBO1)
		{
			return DriveListDraw(hwnd, wParam, (DRAWITEMSTRUCT *)lParam);
		}
		return 0;

	case WM_CLOSE:
		EndDialog(hwnd, 0);
		return TRUE;

	}
	return FALSE;
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
	DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, DlgProc);
	return 0;
}